clear;clc
ym=1.5;
y=linspace(-ym,ym,200);
d1=3;d2=5;z=800;
lambda1=5e-4;lambda2=6e-4;
L1=sqrt((y-1).^2+z^2);
L2=sqrt((y+1).^2+z^2);
phi1=2*pi*(L2-L1)/lambda1;
phi2=2*pi*(L2-L1)/lambda2;
I1=4*cos(phi1/2).^2;
I2=4*cos(phi2/2).^2;
figure((1))
subplot(2,1,1)
plot(y,I1)
axis([-1.5 1.5 0 4])
subplot(2,1,2)
B1=I1*255/5;
image(B1);
colormap(gray(255));
figure((2))
subplot(2,1,1)
plot(y,I2)
axis([-1.5 1.5 0 4])
subplot(2,1,2)
B2=I2*255/5;
image(B2);
colormap(gray(255));